package com.my.study;

public class LockStudy {


    public static volatile int count;

    private static final int NUMBER = 100;


    public static void main(String[] args) {



        MyLock myLock = new LockStudy().new MyLock();
        Thread thread = new Thread(myLock);
        thread.start();
        for(int i =0;i < NUMBER;i++){
            count++;
        }
        //等待线程结束
        while (thread.isAlive()){
        }
        System.out.println("count========" + count);

    }


    class MyLock implements Runnable{

        @Override
        public void run() {
            for(int i =0;i < NUMBER;i++){
                count --;
            }
        }
    }
}
